


***********
*	section 4
* 	appendix table 2: treatment equality. 
clear all
use "data/both.dta"

frame create results
frame change results
set obs 2
gen double mean_r_2s =.
gen double mean_r_1s =.
gen double mean_r_diff =.
gen double mean_r_diff_low =.
gen double mean_r_diff_upp =.
gen double mean_t =.
gen double mean_t_p =.
gen double mean_t_q =.
gen double mean_w2 =.
gen double mean_w2_p =.
gen double mean_w2_q =.



frame change default

drop if exp==1
gen pfamily1 = . // 1st family of tests: does A=B
ttest roll1, by(treatment) // mean, roll 1
replace pfamily1=r(p) if _n==1

frame results: replace mean_r_2s = `r(mu_1)' in 1
frame results: replace mean_r_1s = `r(mu_2)' in 1
frame results: replace mean_r_diff = `r(mu_1)'- `r(mu_2)' in 1
frame results: replace mean_r_diff_low = (`r(mu_1)'- `r(mu_2)')-1.96*`r(se)' in 1
frame results: replace mean_r_diff_upp = (`r(mu_1)'- `r(mu_2)')+1.96*`r(se)' in 1
frame results: replace mean_t = `r(t)' in 1
frame results: replace mean_t_p = `r(p)' in 1

escftest roll1, group(treatment) // distribution, roll 1
frame results: replace mean_w2 = `r(W2)' in 1
frame results: replace mean_w2_p = `r(p_val)' in 1

replace pfamily1=r(p_val) if _n==2
ttest roll2, by(treatment) // mean, roll 2
replace pfamily1=r(p) if _n==3
frame results: replace mean_r_2s = `r(mu_1)' in 2
frame results: replace mean_r_1s = `r(mu_2)' in 2
frame results: replace mean_r_diff = `r(mu_1)'- `r(mu_2)' in 2
frame results: replace mean_r_diff_low = (`r(mu_1)'- `r(mu_2)')-1.96*`r(se)' in 2
frame results: replace mean_r_diff_upp = (`r(mu_1)'- `r(mu_2)')+1.96*`r(se)' in 2
frame results: replace mean_t = `r(t)' in 2
frame results: replace mean_t_p = `r(p)' in 2


escftest roll2, group(treatment) // distribution, roll 2
frame results: replace mean_w2 = `r(W2)' in 2
frame results: replace mean_w2_p = `r(p_val)' in 2
replace pfamily1=r(p_val) if _n==4
qqvalue pfamily1, method(hochberg ) qvalue(qfamily1)
list pfamily1 qfamily1 if qfamily1!=.

sum qfamily if _n==1
frame results: replace mean_t_q = `r(mean)' in 1

sum qfamily if _n==2
frame results: replace mean_w2_q = `r(mean)' in 1

sum qfamily if _n==3
frame results: replace mean_t_q = `r(mean)' in 2

sum qfamily if _n==4
frame results: replace mean_w2_q = `r(mean)' in 2

frame change results
  format *  %9.3f
  
  list
  texsave using "output/appendixtable3.tex", replace 

  
  